投稿時間:2022-10-30 19:12:01 RSSフィード2022-10-30 19:00 分まとめ(11件)
カテゴリー等 | サイト名等 | 記事タイトル・トレンドワード等 | リンクURL | 頻出ワード・要約等/検索ボリューム | 登録日 |
---|---|---|---|---|---|
python | Pythonタグが付けられた新着投稿 - Qiita | 機械学習に役立つ画像収集ライブラリ「icrawler」を使ってみた | https://qiita.com/momiji777/items/1bf228d0d4964f1c6e38 | github | 2022-10-30 18:10:32 |
js | JavaScriptタグが付けられた新着投稿 - Qiita | 【React】Props(children)について | https://qiita.com/seino_914/items/68e35fec6eaeee01e1a1 | propschildren | 2022-10-30 18:59:44 |
js | JavaScriptタグが付けられた新着投稿 - Qiita | iOS16 (執筆時16.3) で、Canvas上でベジェ曲線で画像をマスクするとノイズが発生するときがあるよ。とりあえずノイズを出なくする方法を教えるよ。 | https://qiita.com/sakusan393/items/7c461c7d3b46e18967cf | canvas | 2022-10-30 18:43:23 |
技術ブログ | Developers.IO | EC2のキーペアを失くしたので設定しなおしてみた | https://dev.classmethod.jp/articles/ec2_keypair_and_had_to_reconfigure/ | 設定 | 2022-10-30 09:47:28 |
海外TECH | DEV Community | Material UI Select in React | https://dev.to/refine/material-ui-select-in-react-fm | Material UI Select in ReactAuthor Doro Onome IntroductionMaterial UI provides a plethora of available styled components that assist developers in creating responsive and aesthetically pleasing web designs One of these components is MUIs Select which is an input field that showcases a list of customisable options In this tutorial we will deeply dive into Material UI Select look at its prop possibilities and highlight its features We will also investigate a potential use case in a real world application Steps we ll cover What is Material UIGetting Started with Material UI SelectThe Option componentOther MUI Select featuresIndicatorDecoratorGrouped OptionsClearing the Select fieldAccessibilityBuilding a Sign up Form UI with React and MUI Select What is Material UIMaterial UI is a React framework based on Google s Material Design that contains all the tools required to create a web application Material UI empowers developers to build desktop and mobile web apps for companies by leveraging widely available responsive components Many developers now use Material UI to structure their projects since it simplifies and improves web design The following component categories are available in Material UI Navigation components Input components Data Display components and Surfaces components Select is an illustrative example of an Input component You can add Material UI to your React project with the following commands npm npm install mui material emotion react emotion styledyarn yarn add mui material emotion react emotion styled Getting Started with Material UI SelectThe Material UI Select component displays a pop up with a list of configurable options It emulates the traditional lt Select gt lt Select element in regular HTML The built in props in this component allow you to design interfaces that can be specific to your application s requirements Below is a simple illustration of how to use the Material UI Select component in your next React project import as React from react import Select from mui joy Select import Option from mui joy Option export default function topCarBrands return lt Select defaultValue Benz placeholder Enter Car Brand sx width height gt lt Option value mercedes benz gt Mercedes Benz lt Option gt lt Option value tesla gt Tesla lt Option gt lt Option value rolls royce gt Rolls Royce lt Option gt lt Option value bugatti gt Bugatti lt Option gt lt Option value ferrari gt Ferrari lt Option gt lt Select gt The code above showcases a Material UI Select input field with popular car brands as the option values Here s the result The Option componentThe Option component represents the choosable alternatives in the Select component The selected option inherits the color prop value from the parent Select and by default uses the primary palette It does not however inherit the Select variant value Here s a simple illustration of how to combine them import as React from react import Avatar from mui joy Avatar import ListItemDecorator from mui joy ListItemDecorator import ListDivider from mui joy ListDivider import Select from mui joy Select import Option from mui joy Option export default function topCarBrands return lt Select defaultValue componentsProps listbox sx List decorator size px sx List decorator size px minWidth gt lt Option value gt lt ListItemDecorator gt lt Avatar size sm gt lt ListItemDecorator gt Chevrolet lt Option gt lt ListDivider role none inset startContent gt lt Option value gt lt ListItemDecorator gt lt Avatar size sm gt lt ListItemDecorator gt Honda lt Option gt lt ListDivider role none inset startContent gt lt Option value gt lt ListItemDecorator gt lt Avatar size sm gt lt ListItemDecorator gt Nissan lt Option gt lt ListDivider role none inset startContent gt lt Option value gt lt ListItemDecorator gt lt Avatar size sm gt lt ListItemDecorator gt Ford lt Option gt lt ListDivider role none inset startContent gt lt Option value gt lt ListItemDecorator gt lt Avatar size sm gt lt ListItemDecorator gt Fiat lt Option gt lt Select gt The code above showcases a list of car brands as lt Option gt values The ListItemDecorator component creates space between the avatars while the ListDivider serves as a visual separator Here s the result Tired of repeating your form logic in every place you need it Meet the headless React based solution to build sleek CRUD applications With refine you can be confident that your codebase will always stay clean and boilerplate free Try refine to rapidly build your next CRUD project whether it s an admin panel dashboard internal tool or storefront Other MUI Select features IndicatorYou can modify the default indicator in the lt Select gt lt Select gt component by using the indicator prop The value of the prop can be a string array component or any other React element Consider the code below import as React from react import Select selectClasses from mui joy Select import Option from mui joy Option import KeyboardArrowDown from mui icons material KeyboardArrowDown export default function SelectIndicator return lt Select placeholder what s your favourite car indicator lt KeyboardArrowDown gt sx width amp selectClasses indicator transition s amp selectClasses expanded transform rotate deg gt lt Option value jeep gt Jeep lt Option gt lt Option value volkswagen gt Volkswagen lt Option gt lt Option value volvo gt Volvo lt Option gt lt Option value jaguar gt Jaguar lt Option gt lt Option value audi gt Audi lt Option gt lt Select gt In the code above we used the indicator prop to replace the standard UnfoldMoreIcon with the KeyboardArrowDown icon for the Select options indicator symbol Here s the result DecoratorYou can use the startDecorator and endDecorator props to add supporting icons to the Select input field for more context and better emphasis The startDecorator places the icon at the beginning of the Select field while the endDecorator places the icon at the end Here s an illustration import as React from react import Select from mui joy Select import Option from mui joy Option import Chip from mui joy Chip import AttachMoneyIcon from mui icons material AttachMoney import AddCircleIcon from mui icons material AddCircle export default function SelectDecorators return lt Select placeholder Select a Car… startDecorator lt AttachMoneyIcon gt endDecorator lt AddCircleIcon gt sx width gt lt Option value porsche gt Porsche lt Option gt lt Option value lexus gt Lexus lt Option gt lt Option value land rover gt Land Rover lt Option gt lt Option value toyota gt Toyota lt Option gt lt Option value toyota gt Bugatti lt Option gt lt Select gt The code above depicts a simple Select field with the start and end decorators represented by MUIs AttachMoneyIcon and AddCircleIcon respectively Here s the result Grouped OptionsWrap the Option component in the lt List gt to group your Select option values With the ListItem component you can now provide the Select field with an accompanying label providing uniform height and the easy use of nested CSS variables Consider the code below import as React from react import Select from mui joy Select import Option optionClasses from mui joy Option import Chip from mui joy Chip import List from mui joy List import ListItemDecorator listItemDecoratorClasses from mui joy ListItemDecorator import ListDivider from mui joy ListDivider import ListItem from mui joy ListItem import Typography from mui joy Typography import Check from mui icons material Check export default function Demo const group Land Car Truck Train Motorcycle Bus Water Ship Boat Sub Marine Air Aeroplane Jet Helicopter const colors Land neutral Water primary Air success return lt Select placeholder Choose your transport mode componentsProps listbox component div sx maxHeight overflow auto List padding px sx width gt Object entries group map name transports index gt lt React Fragment key name gt index amp amp lt ListDivider role none gt lt List aria labelledby select group name sx List decorator size px gt lt ListItem id select group name sticky gt lt Typography level body textTransform uppercase letterSpacing md gt name transports length lt Typography gt lt ListItem gt transports map transport gt lt Option key transport value transport label lt React Fragment gt lt Chip size sm color colors name sx borderRadius xs mr ml gt name lt Chip gt transport lt React Fragment gt sx amp optionClasses selected listItemDecoratorClasses root opacity gt lt ListItemDecorator sx opacity gt lt Check gt lt ListItemDecorator gt transport lt Option gt lt List gt lt React Fragment gt lt Select gt The preceding code shows a Select field with organised input values As shown below these values are represented by three modes of transportation land air and water each with its own set of values These values are placed in an array that is mapped through to generate the output on the DOM Note If you wish to specify the maximum height for a list of accessible Select options simply do so in the listbox component to ensure proper keyboard navigation lt Select optionProps listbox sx maxHeight overflow auto to enable scrolling gt Clearing the Select fieldYou can clear the values in the MUI Select field just like any other input component Use the IconButton component as a Select decorator then add the logic that clears the values Here s how import React useState useRef from react import Select from mui joy Select import Option from mui joy Option import IconButton from mui joy IconButton import CloseRounded from mui icons material CloseRounded export default function SelectBasic const value setValue useState tesla const action useRef null return lt Select action action value value placeholder Favorite car onChange e newValue gt setValue newValue value amp amp When the user has selected a value the button is displayed and the select indicator is removed endDecorator lt IconButton size sm variant plain color neutral onMouseDown event gt stops the popup from appearing when this button is clicked event stopPropagation onClick gt setValue null action current focusVisible gt lt CloseRounded gt lt IconButton gt indicator null sx minWidth gt lt Option value tesla gt Tesla lt Option gt lt Option value bmw gt BMW lt Option gt lt Option value bentley gt Bentley lt Option gt lt Option value bugatti gt Bugatti lt Option gt lt Select gt Here s the result AccessibilityTo make MUI Select accessible you must associate it with a label The FormControl component automatically produces a unique id that ties the Select to the FormLabel component Consider the code below lt FormControl gt lt FormLabel id select field demo label htmlFor select field demo button gt Define a random label lt FormLabel gt lt Select componentsProps button id select field demo button aria labelledby select field demo label select field demo button gt lt Option gt lt Option gt lt Select gt lt FormControl gt Note that When making use of FormControl with the outlined variant of the Select component you must provide a label in two places in the InputLabel component and the label prop of the Select component Building a Sign up Form UI with React and MUI SelectYou can use Material UI Select for a wide range of purposes on a website but nothing fully demonstrates its capabilities like a form component For the sake of this tutorial we will showcase the use of MUI Select in a simple Sign up form Here s the code import React useState useRef from react import Select from mui joy Select import Option from mui joy Option import IconButton from mui joy IconButton import CloseRounded from mui icons material CloseRounded export default function SelectBasic const value setValue useState tesla const action useRef null return lt div gt lt section className login gt lt div className loginContainer gt lt label gt Name lt label gt lt input type text autoFocus required gt lt label gt Email lt label gt lt input type email required gt lt label gt Gender lt label gt lt Select action action value value placeholder What is your Gender onChange e newValue gt setValue newValue value amp amp When the user has selected a value the button is displayed and the select indicator is removed endDecorator lt IconButton size sm variant plain color neutral backgroundColor none onMouseDown event gt stops the popup from appearing when this button is clicked event stopPropagation onClick gt setValue null action current focusVisible gt lt CloseRounded gt lt IconButton gt indicator null sx minWidth backgroundColor gt lt Option value male gt Male lt Option gt lt Option value female gt Female lt Option gt lt Option value non binary gt Non Binary lt Option gt lt Option value other gt Other lt Option gt lt Option value no answer gt Prefer not to answer lt Option gt lt Select gt lt div gt lt section gt lt div gt And the result ConclusionThis article covered the Material UI Select component navigated its features and highlighted its functionalities in a React application We also investigated a use case by developing a Sign up form UI in React with MUI Select I hope you find this post helpful | 2022-10-30 09:49:53 |
海外ニュース | Japan Times latest articles | How Halloween parties turned deadly in a popular Seoul district | https://www.japantimes.co.jp/news/2022/10/30/asia-pacific/south-korea-itaewon-crush/ | How Halloween parties turned deadly in a popular Seoul districtThe intimacy of backstreets in the Itaewon district turned sinister this Halloween weekend with a deadly crush killing at least people | 2022-10-30 18:03:55 |
ニュース | BBC News - Home | Suella Braverman email could throw fresh doubt over security breach claims | https://www.bbc.co.uk/news/uk-politics-63444573?at_medium=RSS&at_campaign=KARANGA | message | 2022-10-30 09:52:16 |
北海道 | 北海道新聞 | ソウル雑踏事故で日本人女性2人死亡 | https://www.hokkaido-np.co.jp/article/753094/ | 日本人女性 | 2022-10-30 18:13:00 |
北海道 | 北海道新聞 | ルパンや五ェ門の声優ら浜中でトークショー 飛び入りファンとアフレコも | https://www.hokkaido-np.co.jp/article/753093/ | 釧路管内 | 2022-10-30 18:01:00 |
ビジネス | 東洋経済オンライン | ソウル雑踏事故で「女性の死亡者」が多かった理由 警察・消防は「密集混雑区域」と指定していた | 韓国・北朝鮮 | 東洋経済オンライン | https://toyokeizai.net/articles/-/629524?utm_source=rss&utm_medium=http&utm_campaign=link_back | 東洋経済オンライン | 2022-10-30 18:20:00 |
IT | 週刊アスキー | 冬の代名詞が「やよい軒」にかえってくる! 秋冬は体にしみる“冬鍋”で温まろう | https://weekly.ascii.jp/elem/000/004/111/4111042/ | 秋冬 | 2022-10-30 18:30:00 |
コメント
コメントを投稿