Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import FormControl from '@mui/material/FormControl';

export default function ModernColorSpaces() {
const colorSpaces = [
{ value: 'color(display-p3 0.7 0.5 0)', label: 'display-p3()' }, // Mud
{ value: 'oklch(0.62 0.25 29)', label: 'oklch()' }, // Orange
{ value: 'oklab(0.59 0.1 -0.14)', label: 'oklab()' }, // Purple
{ value: 'hsl(141, 70%, 48%)', label: 'hsl()' }, // Green
{ value: 'rgb(25, 118, 210)', label: 'rgb()' }, // Blue
'color(display-p3 0.7 0.5 0)', // Mud
'oklch(0.62 0.25 29)', // Orange
'oklab(0.59 0.1 -0.14)', // Purple
'hsl(141, 70%, 48%)', // Green
'rgb(25, 118, 210)', // Blue
];

const [selectedColor, setSelectedColor] = React.useState(colorSpaces[0].value);
const [selectedColor, setSelectedColor] = React.useState(colorSpaces[0]);

const theme = React.useMemo(
() =>
Expand All @@ -43,12 +43,12 @@ export default function ModernColorSpaces() {
value={selectedColor}
onChange={(event) => setSelectedColor(event.target.value)}
>
{colorSpaces.map((colorSpace) => (
{colorSpaces.map((value) => (
<FormControlLabel
key={colorSpace.value}
value={colorSpace.value}
key={value}
value={value}
control={<Radio />}
label={colorSpace.value}
label={value}
/>
))}
</RadioGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import FormControl from '@mui/material/FormControl';

export default function ModernColorSpaces() {
const colorSpaces = [
{ value: 'color(display-p3 0.7 0.5 0)', label: 'display-p3()' }, // Mud
{ value: 'oklch(0.62 0.25 29)', label: 'oklch()' }, // Orange
{ value: 'oklab(0.59 0.1 -0.14)', label: 'oklab()' }, // Purple
{ value: 'hsl(141, 70%, 48%)', label: 'hsl()' }, // Green
{ value: 'rgb(25, 118, 210)', label: 'rgb()' }, // Blue
'color(display-p3 0.7 0.5 0)', // Mud
'oklch(0.62 0.25 29)', // Orange
'oklab(0.59 0.1 -0.14)', // Purple
'hsl(141, 70%, 48%)', // Green
'rgb(25, 118, 210)', // Blue
];

const [selectedColor, setSelectedColor] = React.useState(colorSpaces[0].value);
const [selectedColor, setSelectedColor] = React.useState(colorSpaces[0]);

const theme = React.useMemo(
() =>
Expand All @@ -43,12 +43,12 @@ export default function ModernColorSpaces() {
value={selectedColor}
onChange={(event) => setSelectedColor(event.target.value)}
>
{colorSpaces.map((colorSpace) => (
{colorSpaces.map((value) => (
<FormControlLabel
key={colorSpace.value}
value={colorSpace.value}
key={value}
value={value}
control={<Radio />}
label={colorSpace.value}
label={value}
/>
))}
</RadioGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ If native color is not enabled, they will fall back to the JavaScript color mani
The `theme.palette.getContrastText()` function produces the contrast color.
The demo below shows the result of the `theme.palette.getContrastText()` function, which produces the text color based on the selected background.

{{"demo": "ContrastTextDemo.js"}}

:::info
The CSS variables `--__l` and `--__a` are internal variables set globally by Material UI.

Expand Down
Loading