リセットスタイル
Yamada UIは、リセットスタイルをカスタマイズおよび追加する機能を提供しています。
概要
リセットスタイルは、アプリケーション全体で適用されるスタイルです。
テーマに定義されているスタイルはこちらです。
export const resetStyle = defineStyles.resetStyle({
"*, *::before, *::after": {
boxSizing: "border-box",
margin: 0,
padding: 0,
},
"::-webkit-file-upload-button": {
font: "inherit",
WebkitAppearance: "button",
},
"::-webkit-search-cancel-button, ::-webkit-search-decoration": {
WebkitAppearance: "none",
},
"[contenteditable]": {
outline: "none",
},
"[hidden]:where(:not([hidden='until-found']))": {
display: "none !important",
},
"[type='time']::-webkit-calendar-picker-indicator": {
display: "none",
},
a: {
color: "inherit",
textDecoration: "none",
},
"abbr[title]": {
textDecoration: "underline dotted",
},
"b, strong": {
fontWeight: "bolder",
},
"button, input, optgroup, select, textarea": {
appearance: "none",
backgroundColor: "transparent",
border: 0,
borderRadius: 0,
color: "inherit",
font: "inherit",
fontFeatureSettings: "inherit",
fontVariationSettings: "inherit",
letterSpacing: "inherit",
outline: 0,
WebkitAppearance: "none",
},
"code, kbd, samp, pre": {
fontFamily: "inherit",
fontSize: "1em",
},
fieldset: {
border: 0,
minWidth: 0,
},
"h1, h2, h3, h4, h5, h6": {
fontSize: "inherit",
fontWeight: "inherit",
},
hr: {
blockSize: 0,
border: "none",
borderBlockStart: "1px solid",
color: "inherit",
overflow: "visible",
},
html: {
fontFamily:
"system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'",
lineHeight: 1.5,
WebkitTapHighlightColor: "transparent",
WebkitTextSizeAdjust: "100%",
},
"img, svg, video, canvas, audio, iframe, embed, object": {
display: "block",
},
"input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-outer-spin-button":
{
display: "none",
},
"input[type='search']": {
outlineOffset: "-2px",
},
legend: {
display: "table",
float: "left",
width: "100%",
},
mark: {
backgroundColor: "inherit",
color: "inherit",
},
progress: {
verticalAlign: "baseline",
},
small: {
fontSize: "80%",
},
sub: {
bottom: "-0.25em",
},
"sub, sup": {
fontSize: "75%",
lineHeight: 0,
position: "relative",
verticalAlign: "baseline",
},
summary: {
display: "list-item",
},
sup: {
top: "-0.5em",
},
"ul, ol": {
listStyle: "none",
},
"@media (prefers-reduced-motion: no-preference)": {
":where(html:focus-within)": {
scrollBehavior: "smooth",
},
},
":where(html:has(dialog:modal[open]))": {
overflow: "clip",
},
":where(dialog, [popover])": {
background: "none",
border: "none",
color: "inherit",
inset: "unset",
maxHeight: "unset",
maxWidth: "unset",
overflow: "unset",
},
":where(dialog:not([open], [popover]), [popover]:not(:popover-open))": {
display: "none !important",
},
})
カスタマイズ
- 1
- 2
スタイルを変更する
生成したテーマの
styles/reset-style.tsを変更します。theme/styles/reset-style.ts
import { defineStyles } from "@yamada-ui/react" export const resetStyle = defineStyles.resetStyle({ "*, *::before, *::after": { boxSizing: "content-box", margin: 0, padding: 0, }, "::-webkit-file-upload-button": { font: "inherit", WebkitAppearance: "button", }, "::-webkit-search-cancel-button, ::-webkit-search-decoration": { WebkitAppearance: "none", }, "[contenteditable]": { outline: "none", }, "[hidden]:where(:not([hidden='until-found']))": { display: "none !important", }, "[type='time']::-webkit-calendar-picker-indicator": { display: "none", }, a: { color: "inherit", textDecoration: "none", }, "abbr[title]": { textDecoration: "underline dotted", }, "b, strong": { fontWeight: "bolder", }, "button, input, optgroup, select, textarea": { appearance: "none", backgroundColor: "transparent", border: 0, borderRadius: 0, color: "inherit", font: "inherit", fontFeatureSettings: "inherit", fontVariationSettings: "inherit", letterSpacing: "inherit", outline: 0, WebkitAppearance: "none", }, "code, kbd, samp, pre": { fontFamily: "inherit", fontSize: "1em", }, fieldset: { border: 0, minWidth: 0, }, "h1, h2, h3, h4, h5, h6": { fontSize: "inherit", fontWeight: "inherit", }, hr: { blockSize: 0, border: "none", borderBlockStart: "1px solid", color: "inherit", overflow: "visible", }, html: { fontFamily: "system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'", lineHeight: 1.5, WebkitTapHighlightColor: "transparent", WebkitTextSizeAdjust: "100%", }, "img, svg, video, canvas, audio, iframe, embed, object": { display: "block", }, "input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-outer-spin-button": { display: "none", }, "input[type='search']": { outlineOffset: "-2px", }, legend: { display: "table", float: "left", width: "100%", }, mark: { backgroundColor: "inherit", color: "inherit", }, progress: { verticalAlign: "baseline", }, small: { fontSize: "80%", }, sub: { bottom: "-0.25em", }, "sub, sup": { fontSize: "75%", lineHeight: 0, position: "relative", verticalAlign: "baseline", }, summary: { display: "list-item", }, sup: { top: "-0.5em", }, "ul, ol": { listStyle: "none", }, "@media (prefers-reduced-motion: no-preference)": { ":where(html:focus-within)": { scrollBehavior: "smooth", }, }, ":where(html:has(dialog:modal[open]))": { overflow: "clip", }, ":where(dialog, [popover])": { background: "none", border: "none", color: "inherit", inset: "unset", maxHeight: "unset", maxWidth: "unset", overflow: "unset", }, ":where(dialog:not([open], [popover]), [popover]:not(:popover-open))": { display: "none !important", }, }) - 3
プロバイダーを更新する
生成したテーマを
UIProviderに設定します。import { UIProvider } from "@workspaces/ui" import { theme } from "@workspace/theme" const App = () => { return ( <UIProvider theme={theme}> <YourApplication /> </UIProvider> ) }