-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating Multiple Variants #403
Comments
Seems like an array could work, where it would just
|
Currently the |
Okay, thanks for letting me know. |
@jxnblk Any solution to this? I have the same need. Could you consider to re-open this issue? |
I get it working doing this. However, it would be cooler to support this internally. import { useResponsiveValue, useBreakpointIndex } from "@theme-ui/match-media";
import get from "lodash.get";
import theme from "../theme";
function variants(...variantBlocks) {
const variants = useResponsiveValue(variantBlocks);
let styles = {};
variants.map(variant => {
styles = { ...styles, ...get(theme, variant) };
});
return styles;
}
function Example() {
const index = useBreakpointIndex();
return (
<Button
sx={{
...variants(
["buttons.colors.secondary", "buttons.sizes.xs"],
["buttons.colors.primary", "buttons.sizes.lg"]
)
}}
>
Breakpoint index: {index}
</Button>
);
} |
How about comma separated strings? @jxnblk Merry Christmas to y'all 🎅 🎉 |
This approach breaks on breakpoints with e.g. |
I feel like this isn't quite right, but there is the (obvious?) solution of adding a |
I like the `variants` prop 👍 last array item wins I guess?
Lachlan Campbell <[email protected]> schrieb am Mi., 15. Jan. 2020,
17:38:
… I feel like this isn't quite right, but there is the (obvious?) solution
of adding a variants prop that accepts an array of variant values
(strings, or I guess arrays if you want the behavior described above with
breakpoints).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#403?email_source=notifications&email_token=ABHUZK3WEKFPA4BL6LW66Q3Q56F75A5CNFSM4I54YBD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJCCCNI#issuecomment-574890293>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABHUZK4R2656YWXDL7A2QVDQ56F75ANCNFSM4I54YBDQ>
.
|
Yeah, if they conflict, treat it like CSS declarations, the later declarations override the earlier. |
We've discussed adding support for a |
I've made a PR (#586) adding support for this to v0.3! I need a bit of technical help finishing the |
Are there still plans to finish this PR @lachlanjc? Would be awesome. Thanks to everyone for the great work on theme ui! |
@nandorojo I’d love to, unfortunately the surrounding code has changed a bunch while there was discussion & I’ve had a new job/lot going on recently. Not sure if the specific timeline but I’d love to get back to that soon, it’s functionality I’d use every day 🙂 |
I would too @lachlanjc ! :) |
Hi folks. Has this been given any more consideration? It would be a great feature to have for our use case. For example, I need to be able to specify that a button is "disabled" while also being a |
@mryechkin No work on this, but still very much wanted! We recently had a discussion about what the API should look like, over here: #1226 (comment) It needs a fresh PR for implementing, contributions extremely welcome! |
I am looking for a way to create multiple variants for buttons. For example, let's say I want to have the following three variants:
So that I could style a button like this:
This IS possible with style system -- here is an example:
But I can't figure out how to do with with Theme-UI.
Is this possible with Theme-UI? If so, can how can I do it?
Thanks.
The text was updated successfully, but these errors were encountered: