Skip to content
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

SDS does not have button groups (for navigation controls) #84

Open
aganders3 opened this issue May 20, 2024 · 1 comment
Open

SDS does not have button groups (for navigation controls) #84

aganders3 opened this issue May 20, 2024 · 1 comment

Comments

@aganders3
Copy link
Collaborator

I just wanted a place to stash this code. The button groups for @clarsen-czi's designs are based on SDS segmented controls, but I'm not sure those can be adapted for momentary switches instead of stateful toggles. Here's what I came up with using the MUI ButtonGroup that looks pretty close to me. The colors here are hard-coded but there's probably a way to get them from the theme.

import styled from "@emotion/styled";
import { ButtonGroup } from "@mui/material";

const NavButtonGroup = styled(ButtonGroup)({
    "border": "1px solid #EAEAEA", // Add outline to ButtonGroup
    "& .MuiButtonBase-root": {
        "borderRadius": 0, // Remove rounded corners
        "borderRight": "1px solid #EAEAEA", // Add dividers between buttons
        "padding": "0.1em 0.2em", // Add padding to buttons
        "&:last-child": {
            borderRight: "none", // Remove borderRight on last button
        },
        "&:active": {
            color: "#3867FA", // Change text color when pressed
            backgroundColor: "#CCCCCC", // Change background color when pressed
        },
    },
});

Screenshot of the design (not the above code) for reference:
Screenshot 2024-05-20 at 9 28 47 AM

@ehoops-cz
Copy link
Collaborator

If we're using the default theme, we can use these css variables from sds in an sx prop. If it makes more sense to use a styled component, czgenepi has examples

import "@czi-sds/components/dist/variables.css";
sx={{
    borderRadius: "var(--sds-corner-m)",
}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants