Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

variants.ts

58 lines3.0 KB

1import { type VariantProps, cva } from './utils'
2​
3const buttonVariants = cva({
4 variants: {
5 base: {
6 true: 'relative inline-flex select-none items-center justify-center whitespace-nowrap rounded-md font-sora text-sm font-medium text-black dark:text-white transition-colors focus-visible:z-20 focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-1 focus-visible:outline-blue-500 disabled:pointer-events-none disabled:opacity-50',
7 },
8 variant: {
9 primary:
10 'bg-blue-500 text-white dark:text-white transition duration-200 hover:-translate-y-1 hover:bg-blue-500/90 hover:shadow-lg hover:shadow-blue-600/90 focus-visible:-translate-y-1 focus-visible:bg-blue/90 focus-visible:shadow-lg focus-visible:shadow-blue-600/90',
11 secondary:
12 'bg-gray-500 text-white dark:text-white transition duration-200 hover:-translate-y-1 hover:bg-gray-500/90 hover:shadow-lg hover:shadow-gray-600/90 focus-visible:-translate-y-1 focus-visible:bg-gray-500/90 focus-visible:shadow-lg focus-visible:shadow-gray-600/90',
13 outline:
14 'border border-gray-300 bg-white dark:bg-black hover:bg-accent/50 focus-visible:bg-accent/50 dark:border-gray-700',
15 ghost:
16 'hover:bg-gray-200 focus-visible:bg-gray-200 hover:dark:bg-gray-800 focus-visible:dark:bg-gray-800',
17 opacity:
18 'opacity-75 transition-opacity hover:opacity-100 focus-visible:opacity-100',
19 link: 'underline-offset-4 hover:underline',
20 },
21 size: {
22 xs: 'h-6 px-2.5',
23 sm: 'h-8 p-1',
24 md: 'h-10 px-4 py-2',
25 icon: 'h-10 w-10',
26 },
27 },
28})
29​
30type buttonVariantProps = VariantProps<typeof buttonVariants>
31​
32const inputVariants = cva({
33 base: 'peer select-none appearance-none border focus:ring-0 focus:ring-offset-0 border-gray-300 transition-colors focus-visible:border-blue-500 disabled:cursor-not-allowed disabled:opacity-50 dark:border-gray-700 focus-visible:dark:border-blue-500',
34 variants: {
35 type: {
36 text: 'flex h-10 w-full rounded-md bg-white dark:bg-black px-3 py-2 text-sm placeholder:text-gray-500',
37 password:
38 'flex h-10 w-full rounded-md bg-white dark:bg-black px-3 py-2 text-sm placeholder:text-gray-500',
39 tel: 'flex h-10 w-full rounded-md bg-white dark:bg-black px-3 py-2 text-sm placeholder:text-gray-500',
40 checkbox:
41 'h-4 w-4 cursor-pointer rounded-sm bg-white dark:bg-black transition-colors checked:border-blue-500 checked:bg-blue-500 checked:hover:bg-blue-500 checked:focus:bg-blue-500 checked:dark:border-blue-500',
42 number:
43 'flex h-10 w-full rounded-md bg-white dark:bg-black px-3 py-2 text-sm [appearance:textfield] placeholder:text-gray-500 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none',
44 },
45 invalid: {
46 true: 'border-red-500 focus-visible:border-red-500 dark:border-red-500 focus-visible:dark:border-red-500',
47 },
48 },
49})
50​
51type inputVariantProps = VariantProps<typeof inputVariants>
52​
53export {
54 buttonVariants,
55 inputVariants,
56 type buttonVariantProps,
57 type inputVariantProps,