この記事は 2025 年 6 月 21 日に投稿しました。
目次
リンク
1. はじめに
こんにちは、iOS のエディタアプリPWEditorとその後継PWEditor2の開発者の二俣です。
今回はReactのMaterial UIのステッパーでラベルをアイコンの下に表示する方法についてです。
2. ReactのMaterial UIのステッパーでラベルをアイコンの下に表示する
ReactのMaterail UIのステッパーでラベルをアイコンの下に表示するには、alternativeLabelプロパティを設定します。
実装例
※create-react-appで作成したTypeScriptのプロジェクトです。
index.tsx
import React from "react"; import ReactDOM from "react-dom/client"; import App from "./App"; const root = ReactDOM.createRoot( document.getElementById("root") as HTMLElement ); root.render( <React.StrictMode> <App /> </React.StrictMode> );
App.tsx
import * as React from "react"; import Box from "@mui/material/Box"; import Stepper from "@mui/material/Stepper"; import Step from "@mui/material/Step"; import StepLabel from "@mui/material/StepLabel"; const steps = [ "Select master blaster campaign settings", "Create an ad group", "Create an ad", ]; export default function HorizontalLinearAlternativeLabelStepper() { return ( <Box sx={{ width: "20%", margin: 8 }}> <Stepper activeStep={1} alternativeLabel> {steps.map((label) => ( <Step key={label}> <StepLabel>{label}</StepLabel> </Step> ))} </Stepper> </Box> ); }
実行結果
リファレンス
3. おわりに
ラベルをアイコンの下に表示できると、表示幅を節約できます。
リンク
紹介している一部の記事のコードはGitlabで公開しています。
興味のある方は覗いてみてください。
私が勤務しているニューラルでは、主に組み込み系ソフトの開発を行っております。
弊社製品のハイブリッド OS Bi-OSは高い技術力を評価されており、特に制御系や通信系を得意としています。
私自身はiOS モバイルアプリやウィンドウズアプリを得意としております。
ソフトウェア開発に関して相談などございましたら、お気軽にご連絡ください。
また一緒に働きたい技術者の方も随時募集中です。
興味がありましたらご連絡ください。
EMAIL : info-nr@newral.co.jp / m-futamata@newral.co.jp
TEL : 042-523-3663
FAX : 042-540-1688