diff --git a/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/css/index.js b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/css/index.js new file mode 100644 index 0000000000..31331694ff --- /dev/null +++ b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/css/index.js @@ -0,0 +1,152 @@ +'use client'; + +import * as React from 'react'; +import * as Checkbox from '@base_ui/react/Checkbox'; +import * as CheckboxGroup from '@base_ui/react/CheckboxGroup'; +import * as Field from '@base_ui/react/Field'; +import Check from '@mui/icons-material/Check'; + +export default function UnstyledCheckboxIndeterminateGroup() { + return ( + +
+ + Colors +
+ + + + + + + Red + + + + + + + + Green + + + + + + + + Blue + +
+
+ +
+
+ ); +} + +const grey = { + 100: '#E5EAF2', + 300: '#C7D0DD', + 500: '#9DA8B7', + 600: '#6B7A90', + 800: '#303740', + 900: '#1C2025', +}; + +function Styles() { + return ( + + ); +} diff --git a/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/css/index.tsx b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/css/index.tsx new file mode 100644 index 0000000000..31331694ff --- /dev/null +++ b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/css/index.tsx @@ -0,0 +1,152 @@ +'use client'; + +import * as React from 'react'; +import * as Checkbox from '@base_ui/react/Checkbox'; +import * as CheckboxGroup from '@base_ui/react/CheckboxGroup'; +import * as Field from '@base_ui/react/Field'; +import Check from '@mui/icons-material/Check'; + +export default function UnstyledCheckboxIndeterminateGroup() { + return ( + +
+ + Colors +
+ + + + + + + Red + + + + + + + + Green + + + + + + + + Blue + +
+
+ +
+
+ ); +} + +const grey = { + 100: '#E5EAF2', + 300: '#C7D0DD', + 500: '#9DA8B7', + 600: '#6B7A90', + 800: '#303740', + 900: '#1C2025', +}; + +function Styles() { + return ( + + ); +} diff --git a/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/system/index.js b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/system/index.js new file mode 100644 index 0000000000..26b73c5315 --- /dev/null +++ b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/system/index.js @@ -0,0 +1,125 @@ +'use client'; + +import * as React from 'react'; +import { css, styled } from '@mui/system'; +import * as BaseCheckbox from '@base_ui/react/Checkbox'; +import * as CheckboxGroup from '@base_ui/react/CheckboxGroup'; +import * as Field from '@base_ui/react/Field'; +import Check from '@mui/icons-material/Check'; + +export default function UnstyledCheckboxIndeterminateGroup() { + return ( +
+ + + Colors +
+ + + + + + + Red + + + + + + + + Green + + + + + + + + Blue + +
+
+
+
+ ); +} + +const blue = { + 400: '#3399FF', + 600: '#0072E6', + 800: '#004C99', +}; + +const grey = { + 100: '#E5EAF2', + 400: '#B0B8C4', + 800: '#303740', +}; + +const labelStyles = css` + display: flex; + gap: 8px; + margin-bottom: 8px; +`; + +const FieldRoot = styled(Field.Root)` + display: flex; +`; + +const CheckboxLabel = styled(Field.Label)` + ${labelStyles} + padding-left: 8px; +`; + +const CheckboxGroupLabel = styled(Field.Label)` + font-size: 17px; + font-weight: bold; + ${labelStyles} +`; + +const Checkbox = styled(BaseCheckbox.Root)( + ({ theme }) => ` + width: 24px; + height: 24px; + padding: 0; + border-radius: 4px; + border: 2px solid ${blue[600]}; + background: none; + transition-property: background, border-color; + transition-duration: 0.15s; + outline: none; + + &[data-disabled] { + opacity: 0.4; + cursor: not-allowed; + } + + &:focus-visible { + outline: 2px solid ${theme.palette.mode === 'dark' ? blue[800] : blue[400]}; + outline-offset: 2px; + } + + &[data-state="checked"], &[data-state="mixed"] { + border-color: transparent; + background: ${blue[600]}; + } + `, +); + +const CheckIcon = styled(Check)` + height: 100%; + width: 100%; +`; + +const Indicator = styled(BaseCheckbox.Indicator)` + height: 100%; + display: inline-block; + visibility: hidden; + color: ${grey[100]}; + + &[data-state='checked'], + &[data-state='mixed'] { + visibility: visible; + } +`; diff --git a/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/system/index.tsx b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/system/index.tsx new file mode 100644 index 0000000000..26b73c5315 --- /dev/null +++ b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/system/index.tsx @@ -0,0 +1,125 @@ +'use client'; + +import * as React from 'react'; +import { css, styled } from '@mui/system'; +import * as BaseCheckbox from '@base_ui/react/Checkbox'; +import * as CheckboxGroup from '@base_ui/react/CheckboxGroup'; +import * as Field from '@base_ui/react/Field'; +import Check from '@mui/icons-material/Check'; + +export default function UnstyledCheckboxIndeterminateGroup() { + return ( +
+ + + Colors +
+ + + + + + + Red + + + + + + + + Green + + + + + + + + Blue + +
+
+
+
+ ); +} + +const blue = { + 400: '#3399FF', + 600: '#0072E6', + 800: '#004C99', +}; + +const grey = { + 100: '#E5EAF2', + 400: '#B0B8C4', + 800: '#303740', +}; + +const labelStyles = css` + display: flex; + gap: 8px; + margin-bottom: 8px; +`; + +const FieldRoot = styled(Field.Root)` + display: flex; +`; + +const CheckboxLabel = styled(Field.Label)` + ${labelStyles} + padding-left: 8px; +`; + +const CheckboxGroupLabel = styled(Field.Label)` + font-size: 17px; + font-weight: bold; + ${labelStyles} +`; + +const Checkbox = styled(BaseCheckbox.Root)( + ({ theme }) => ` + width: 24px; + height: 24px; + padding: 0; + border-radius: 4px; + border: 2px solid ${blue[600]}; + background: none; + transition-property: background, border-color; + transition-duration: 0.15s; + outline: none; + + &[data-disabled] { + opacity: 0.4; + cursor: not-allowed; + } + + &:focus-visible { + outline: 2px solid ${theme.palette.mode === 'dark' ? blue[800] : blue[400]}; + outline-offset: 2px; + } + + &[data-state="checked"], &[data-state="mixed"] { + border-color: transparent; + background: ${blue[600]}; + } + `, +); + +const CheckIcon = styled(Check)` + height: 100%; + width: 100%; +`; + +const Indicator = styled(BaseCheckbox.Indicator)` + height: 100%; + display: inline-block; + visibility: hidden; + color: ${grey[100]}; + + &[data-state='checked'], + &[data-state='mixed'] { + visibility: visible; + } +`; diff --git a/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/tailwind/index.js b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/tailwind/index.js new file mode 100644 index 0000000000..41a8de1373 --- /dev/null +++ b/docs/data/base/components/checkbox-group/UnstyledCheckboxGroupIntroduction/tailwind/index.js @@ -0,0 +1,126 @@ +'use client'; + +import * as React from 'react'; +import PropTypes from 'prop-types'; +import { useTheme } from '@mui/system'; +import * as BaseCheckbox from '@base_ui/react/Checkbox'; +import * as CheckboxGroup from '@base_ui/react/CheckboxGroup'; +import * as Field from '@base_ui/react/Field'; +import Check from '@mui/icons-material/Check'; + +function classNames(...classes) { + return classes.filter(Boolean).join(' '); +} + +function useIsDarkMode() { + const theme = useTheme(); + return theme.palette.mode === 'dark'; +} + +function Label(props) { + return ( + // eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/no-noninteractive-element-interactions +