/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/data/material/guides/localization/Locales.js
45 строк
1 KB
Siriwat K
[docs] Migrate content to the new location (#30757)
04 фев 2022, 07:13
Не верифицирован
04 фев 2022, 07:13
27f1c28
Код
Авторство
О чём код?
import * as React from 'react'; import TablePagination from '@mui/material/TablePagination'; import Autocomplete from '@mui/material/Autocomplete'; import Box from '@mui/material/Box'; import TextField from '@mui/material/TextField'; import { createTheme, ThemeProvider, useTheme } from '@mui/material/styles'; import * as locales from '@mui/material/locale'; export default function Locales() { const [locale, setLocale] = React.useState('zhCN'); const theme = useTheme(); const themeWithLocale = React.useMemo( () => createTheme(theme, locales[locale]), [locale, theme], ); return ( <Box sx={{ width: '100%' }}> <ThemeProvider theme={themeWithLocale}> <Autocomplete options={Object.keys(locales)} getOptionLabel={(key) => `${key.substring(0, 2)}-${key.substring(2, 4)}`} style={{ width: 300 }} value={locale} disableClearable onChange={(event, newValue) => { setLocale(newValue); }} renderInput={(params) => ( <TextField {...params} label="Locale" fullWidth /> )} /> <TablePagination count={2000} rowsPerPage={10} page={1} component="div" onPageChange={() => {}} /> </ThemeProvider> </Box> ); }