mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(docs): custom impl preview for checkbox & checkbox-grp (#4610)
This commit is contained in:
parent
aef47ffbf4
commit
6f594fa530
@ -1,26 +1,26 @@
|
||||
import {useCheckbox, CheckboxGroup, Chip, VisuallyHidden, tv} from "@heroui/react";
|
||||
|
||||
const checkbox = tv({
|
||||
slots: {
|
||||
base: "border-default hover:bg-default-200",
|
||||
content: "text-default-500",
|
||||
},
|
||||
variants: {
|
||||
isSelected: {
|
||||
true: {
|
||||
base: "border-primary bg-primary hover:bg-primary-500 hover:border-primary-500",
|
||||
content: "text-primary-foreground pl-1",
|
||||
},
|
||||
},
|
||||
isFocusVisible: {
|
||||
true: {
|
||||
base: "outline-none ring-2 ring-focus ring-offset-2 ring-offset-background",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const CustomCheckbox = (props) => {
|
||||
const checkbox = tv({
|
||||
slots: {
|
||||
base: "border-default hover:bg-default-200",
|
||||
content: "text-default-500",
|
||||
},
|
||||
variants: {
|
||||
isSelected: {
|
||||
true: {
|
||||
base: "border-primary bg-primary hover:bg-primary-500 hover:border-primary-500",
|
||||
content: "text-primary-foreground pl-1",
|
||||
},
|
||||
},
|
||||
isFocusVisible: {
|
||||
true: {
|
||||
base: "outline-none ring-2 ring-focus ring-offset-2 ring-offset-background",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const {children, isSelected, isFocusVisible, getBaseProps, getLabelProps, getInputProps} =
|
||||
useCheckbox({
|
||||
...props,
|
||||
|
||||
@ -20,32 +20,32 @@ export const CheckIcon = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const checkbox = tv({
|
||||
slots: {
|
||||
base: "border-default hover:bg-default-200",
|
||||
content: "text-default-500",
|
||||
},
|
||||
variants: {
|
||||
isSelected: {
|
||||
true: {
|
||||
base: "border-primary bg-primary hover:bg-primary-500 hover:border-primary-500",
|
||||
content: "text-primary-foreground pl-1",
|
||||
},
|
||||
},
|
||||
isFocusVisible: {
|
||||
true: {
|
||||
base: "outline-none ring-2 ring-focus ring-offset-2 ring-offset-background",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default function App() {
|
||||
const {children, isSelected, isFocusVisible, getBaseProps, getLabelProps, getInputProps} =
|
||||
useCheckbox({
|
||||
defaultSelected: true,
|
||||
});
|
||||
|
||||
const checkbox = tv({
|
||||
slots: {
|
||||
base: "border-default hover:bg-default-200",
|
||||
content: "text-default-500",
|
||||
},
|
||||
variants: {
|
||||
isSelected: {
|
||||
true: {
|
||||
base: "border-primary bg-primary hover:bg-primary-500 hover:border-primary-500",
|
||||
content: "text-primary-foreground pl-1",
|
||||
},
|
||||
},
|
||||
isFocusVisible: {
|
||||
true: {
|
||||
base: "outline-none ring-2 ring-focus ring-offset-2 ring-offset-background",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const styles = checkbox({isSelected, isFocusVisible});
|
||||
|
||||
return (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user