Material UI core shine kyakkyawan bayani ga masu haษaka React waษanda ke son amfani da abubuwan da aka riga aka gina don haษakawa cikin sauri. Ya shahara don abubuwan gani-na gani da abubuwan da suka dace da masu amfani waษanda ke kawo aiki da sauฦi ga tsarin ฦira. Material-UI ya mallaki abubuwa sama da 50, duk an tsara su don adana lokacin haษakawa da kuzari. Yanzu, bari mu nutse kan yadda ake saita Material UI core don aikace-aikacen ku.
Saita Material-UI
Lokacin da yazo don saita Material-UI, duk yana farawa da shigarwa.
npm install @material-ui/core
Wannan umarnin zai shigar da ainihin fakitin Material-UI a cikin aikace-aikacenku. Yana da mahimmanci don tabbatar da cewa an saita mahallin ku don gudanar da JavaScript ko kuma wannan umarni na iya gazawa.
Da zarar an shigar da Material-UI core, yanzu zaku iya shigo da amfani da sashin sa a cikin aikace-aikacenku.
import Button from '@material-ui/core/Button'; function App() { return <Button color="primary">Hello World</Button>; } export default App;
A cikin snippet lambar da ke sama, muna da aikace-aikace mai sauฦi inda muka shigo da maษalli daga Material-UI core kuma muka yi amfani da shi a cikin aikin mu na App.
Zurfafa zurfafa cikin Kayan-UI's Core Components
Material UI core yana da fiye da 50 abubuwan da aka riga aka ฦayyade waษanda ke biyan buฦatu daban-daban a cikin shimfidar aikace-aikacen. Yawancin waษannan abubuwan haษin gwiwar ana iya daidaita su kuma suna ba da sassauci mai yawa ga masu haษakawa. Wasu sanannun misalan sun haษa da katunan, baji, maษalli, akwatunan rajista, gumaka, da ฦari mai yawa.
Don amfani da waษannan abubuwan haษin, kuna buฦatar kawai shigo da hadewa su a cikin lambar ku daidai. Misali, sauฦin amfani da mashaya ci gaba na Material-UI zai yi kama da haka:
import CircularProgress from '@material-ui/core/CircularProgress'; function CircularIndeterminate() { return <CircularProgress />; }
A cikin lambar da ke sama, mun shigo da bangaren CircularProgress don nuna alamar lodi.
ฦarfin Material-UI Jigo
ฦaya daga cikin abubuwan ban mamaki na Material-UI shine ฦarfin jigon sa. Ta hanyar naษe aikace-aikacenku tare da ษangaren ThemeProvider da samar da shi jigo, zaku iya canza kamannin aikace-aikacenku gaba ษaya.
Bari mu bincika misali mai sauฦi:
import { ThemeProvider, createMuiTheme } from '@material-ui/core/styles'; import purple from '@material-ui/core/colors/purple'; const theme = createMuiTheme({ palette: { primary: purple, }, }); <ThemeProvider theme={theme}> <Button color="primary">A purple theme button</Button> </ThemeProvider>
A cikin wannan misalin, mun ฦirฦiri jigo mai launin fari na shuษi, sannan muka naษe aikace-aikacenmu tare da ษangaren ThemeProvider.
Material-UI core ya fito waje azaman kayan aiki mai mahimmanci don haษaka saurin haษakawa da haษaka aiki a cikin haษaka React. Ko ya kasance kayan aikin sa masu ban sha'awa, damar gyare-gyare, ko zaษuษษukan jigo masu ฦarfi, abin tafiya ne ga masu haษakawa waษanda ke neman ฦirฦirar mu'amala mai ma'ana da jan hankali.