An warware: shigarwa na kayan ui core ta amfani da

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.

Shafi posts:

Leave a Comment