Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function useTabbableProps(
{
// Setting `primary` here and not in `useTabbableOptions` because we want
// it to default to `primary` only for the tabbable `box-shadow`
unstable_system: { palette = "primary", ...system } = {}
}: BootstrapTabbableOptions,
htmlProps: TabbableHTMLProps = {}
): TabbableHTMLProps {
const {
style: { color, backgroundColor }
} = usePaletteBoxProps({ unstable_system: { palette, ...system } });
const dark = usePalette("dark") || "black";
const background = usePalette("background") || "white";
const backgroundIsLight = useIsLight(background);
const strokeColor = backgroundColor || color || dark;
const contrastRatio = useContrastRatio(background, strokeColor);
const darker = useDarken(strokeColor, contrastRatio < 1.2 ? 0.25 : 0);
const lighter = useLighten(strokeColor, contrastRatio < 1.2 ? 0.25 : 0);
const boxShadowColor = useFade(backgroundIsLight ? darker : lighter, 0.6);
const tabbable = css`
&:not([type="checkbox"]):not([type="radio"]) {
transition: box-shadow 0.15s ease-in-out;
outline: 0;
&:focus {
box-shadow: 0 0 0 0.2em ${boxShadowColor};
position: relative;
export function useTabbableProps(
{
// Setting `primary` here and not in `useTabbableOptions` because we want
// it to default to `primary` only for the tabbable `box-shadow`
unstable_system: { palette = "primary", ...system } = {}
}: BootstrapTabbableOptions,
htmlProps: TabbableHTMLProps = {}
): TabbableHTMLProps {
const {
style: { color, backgroundColor }
} = usePaletteBoxProps({ unstable_system: { palette, ...system } });
const dark = usePalette("dark") || "black";
const background = usePalette("background") || "white";
const backgroundIsLight = useIsLight(background);
const strokeColor = backgroundColor || color || dark;
const contrastRatio = useContrastRatio(background, strokeColor);
const darker = useDarken(strokeColor, contrastRatio < 1.2 ? 0.25 : 0);
const lighter = useLighten(strokeColor, contrastRatio < 1.2 ? 0.25 : 0);
const boxShadowColor = useFade(backgroundIsLight ? darker : lighter, 0.6);
const tabbable = css`
&:not([type="checkbox"]):not([type="radio"]) {
transition: box-shadow 0.15s ease-in-out;
outline: 0;
&:focus {
box-shadow: 0 0 0 0.2em ${boxShadowColor};
position: relative;
z-index: 2;
export function useSeparatorProps(
_: BootstrapSeparatorOptions,
htmlProps: SeparatorHTMLProps = {}
): SeparatorHTMLProps {
const foreground = usePalette("foreground") || "black";
const borderColor = useFade(foreground, 0.75);
const separator = css`
border: 1px solid ${borderColor};
border-width: 0 1px 0 0;
margin: 0 0.5em;
padding: 0;
width: 0;
height: auto;
&[aria-orientation="horizontal"] {
border-width: 0 0 1px 0;
margin: 0.5em 0;
width: auto;
height: 0;
}
export function useFormInputProps(
{ unstable_system }: BootstrapFormInputOptions,
htmlProps: unstable_FormInputHTMLProps = {}
): unstable_FormInputHTMLProps {
const {
style: { backgroundColor, borderColor: originalBorderColor }
} = usePaletteBoxProps({ unstable_system });
const foreground = useContrast(backgroundColor) || "black";
const color = useLighten(foreground, 0.3);
const primary = usePalette("primary");
const borderColor = useFade(foreground, 0.75);
const focusBorderColor = useLighten(primary, 0.4);
const formInput = css`
display: block;
width: 100%;
border-radius: 0.2rem;
padding: 0.5em 0.75em;
font-size: 100%;
border: 1px solid ${originalBorderColor || borderColor};
color: ${color};
margin: 0 !important;
&:focus {
border-color: ${originalBorderColor || focusBorderColor};
}
export function useMenuItemProps(
{ unstable_system, ...options }: BootstrapMenuItemOptions,
htmlProps: MenuItemHTMLProps = {}
): MenuItemHTMLProps {
const foreground = usePalette("foreground") || "black";
const primary = usePalette("primary") || "blue";
const primaryContrast = useContrast(primary);
const darkPrimary = useDarken(primary, 0.2);
const isHorizontal = options.orientation === "horizontal";
const menuItem = css`
&&& {
line-height: 1.5;
padding: 0 ${isHorizontal ? "0.5em" : "1.5em"};
text-align: left;
justify-content: flex-start;
border: 0;
border-radius: 0;
font-size: 100%;
background: transparent;
color: ${foreground};
export function useTabProps(
_: BootstrapTabOptions,
htmlProps: TabHTMLProps = {}
): TabHTMLProps {
const background = usePalette("background") || "white";
const foreground = usePalette("foreground") || "black";
const borderColor = useFade(foreground, 0.75);
const tab = css`
background-color: transparent;
border: 1px solid transparent;
border-width: 1px 1px 0 1px;
border-radius: 0.25rem 0.25rem 0 0;
font-size: 100%;
padding: 0.5em 1em;
margin: 0 0 -1px 0;
&[aria-selected="true"] {
background-color: ${background};
border-color: ${borderColor};
}
export function useMenuItemProps(
{ unstable_system, ...options }: BootstrapMenuItemOptions,
htmlProps: MenuItemHTMLProps = {}
): MenuItemHTMLProps {
const foreground = usePalette("foreground") || "black";
const primary = usePalette("primary") || "blue";
const primaryContrast = useContrast(primary);
const darkPrimary = useDarken(primary, 0.2);
const isHorizontal = options.orientation === "horizontal";
const menuItem = css`
&&& {
line-height: 1.5;
padding: 0 ${isHorizontal ? "0.5em" : "1.5em"};
text-align: left;
justify-content: flex-start;
border: 0;
border-radius: 0;
font-size: 100%;
background: transparent;
color: ${foreground};
margin: 0;
export function useTabProps(
_: BootstrapTabOptions,
htmlProps: TabHTMLProps = {}
): TabHTMLProps {
const background = usePalette("background") || "white";
const foreground = usePalette("foreground") || "black";
const borderColor = useFade(foreground, 0.75);
const tab = css`
background-color: transparent;
border: 1px solid transparent;
border-width: 1px 1px 0 1px;
border-radius: 0.25rem 0.25rem 0 0;
font-size: 100%;
padding: 0.5em 1em;
margin: 0 0 -1px 0;
&[aria-selected="true"] {
background-color: ${background};
border-color: ${borderColor};
}
export function useTabListProps(
_: BootstrapTabListOptions,
htmlProps: TabListHTMLProps = {}
): TabListHTMLProps {
const foreground = usePalette("foreground") || "black";
const borderColor = useFade(foreground, 0.75);
const tabList = css`
display: flex;
flex-direction: row;
border: 1px solid ${borderColor};
border-width: 0 0 1px 0;
margin: 0 0 1em 0;
&[aria-orientation="vertical"] {
flex-direction: column;
border-width: 0 1px 0 0;
margin: 0 1em 0 0;
}
`;
export function useDialogProps(
{ unstable_system }: BootstrapDialogOptions,
htmlProps: DialogHTMLProps = {}
): DialogHTMLProps {
const {
style: { color, backgroundColor }
} = usePaletteBoxProps({ unstable_system });
const foreground = useContrast(backgroundColor) || "black";
const primaryColor = usePalette("primary");
const borderColor = useFade(foreground, 0.75);
const boxShadowColor = useFade(primaryColor || color || foreground, 0.5);
const dialog = css`
position: fixed;
top: 28px;
left: 50%;
transform: translateX(-50%);
border-radius: 0.25rem;
padding: 1em;
max-height: calc(100vh - 56px);
outline: 0;
border: 1px solid ${borderColor};
color: ${color};
z-index: 999;