Skip to content

Multiple values in styled defaultVariant #313

@iamursky

Description

@iamursky

I’m trying to achieve variant composition as shown in the example below, but the styled function’s defaultVariant option only accepts a single value. Since the Button component can take an array of variants <Button variant={["solid", "md"]} />, I’m wondering why defaultVariant doesn’t accept an array as well.

import { makeTheme } from "dripsy";
import { Pressable, styled, Text } from "dripsy";

const theme = makeTheme({
  buttons: {
    solid: {
      color: "white",
      backgroundColor: "primary",
    },
    md: {
      fontSize: "p",
      paddingX: 16,
      paddingY: 8,
    },
  },
});

const Button = styled(Pressable, {
  themeKey: "buttons",
  defaultVariant: ["solid", "md"], // <- accept a single value only
})();

const ButtonText = styled(Text)({
  color: "inherit",
  fontFamily: "inherit",
  fontSize: "inherit",
  textDecorationLine: "inherit",
});

function UsageExample() {
  return (
    <Button>
      <ButtonText>Change privacy settings</ButtonText>
    </Button>
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions