MCPcopy Create free account
hub / github.com/primer/react / getVariantStyles

Function getVariantStyles

packages/react/src/Button/styles.ts:4–204  ·  view source on GitHub ↗
(variant: VariantType = 'default', theme?: Theme)

Source from the content-addressed store, hash-verified

2import type {Theme} from '../ThemeProvider'
3
4export const getVariantStyles = (variant: VariantType = 'default', theme?: Theme) => {
5 const style = {
6 default: {
7 color: 'btn.text',
8 backgroundColor: 'btn.bg',
9 boxShadow: `${theme?.shadows.btn.shadow}, ${theme?.shadows.btn.insetShadow}`,
10 '&:hover:not([disabled]):not([data-inactive])': {
11 backgroundColor: 'btn.hoverBg',
12 borderColor: `var(--button-default-borderColor-hover, ${theme?.colors.btn.hoverBorder})`,
13 },
14 '&:active:not([disabled]):not([data-inactive])': {
15 backgroundColor: 'btn.activeBg',
16 borderColor: `var(--button-default-borderColor-active, ${theme?.colors.btn.activeBorder})`,
17 },
18 '&:disabled': {
19 color: 'primer.fg.disabled',
20 borderColor: `var(--button-default-borderColor-disabled, ${theme?.colors.btn.border})`,
21 backgroundColor: `var(--button-default-bgColor-disabled, ${theme?.colors.input.disabledBg})`,
22 '[data-component=ButtonCounter]': {
23 color: 'inherit',
24 },
25 },
26 '&[aria-expanded=true]': {
27 backgroundColor: 'btn.activeBg',
28 borderColor: `var(--button-default-borderColor-active, ${theme?.colors.btn.activeBorder})`,
29 },
30 '[data-component="leadingVisual"], [data-component="trailingVisual"], [data-component="trailingAction"]': {
31 color: `var(--button-color, ${theme?.colors.fg.muted})`,
32 },
33 '[data-component=ButtonCounter]': {
34 backgroundColor: 'btn.counterBg',
35 },
36 '&[data-component="IconButton"][data-no-visuals]': {
37 color: 'fg.muted',
38 },
39 },
40 primary: {
41 color: 'btn.primary.text',
42 backgroundColor: 'btn.primary.bg',
43 borderColor: 'btn.primary.border',
44 boxShadow: `${theme?.shadows.btn.primary.shadow}`,
45 '&:hover:not([disabled]):not([data-inactive])': {
46 color: 'btn.primary.hoverText',
47 backgroundColor: 'btn.primary.hoverBg',
48 },
49 '&:focus:not([disabled])': {
50 boxShadow: 'inset 0 0 0 3px',
51 },
52 '&:focus-visible:not([disabled])': {
53 boxShadow: 'inset 0 0 0 3px',
54 },
55 '&:active:not([disabled]):not([data-inactive])': {
56 backgroundColor: 'btn.primary.selectedBg',
57 boxShadow: `${theme?.shadows.btn.primary.selectedShadow}`,
58 },
59 '&:disabled': {
60 color: 'btn.primary.disabledText',
61 backgroundColor: 'btn.primary.disabledBg',

Callers 1

ButtonBase.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected