Skip to content

How to use pseudo class :not(:first-child) by @fluentui/react-make-styles? #18549

Answered by miroslavstastny
yifanwww asked this question in Q&A
Discussion options

You must be logged in to vote

:not(:first-child) selector is equivalent of &:not(:first-child) and applies to the list selector in the example. If the generated classname for the list slot is list-1234, the selector is .list-1234:not(:first-child).

But you want it to be applied to list's children - in that case you need to use & :not(:first-child) (with & and SPACE) in the selector to identify children:

const useClasses = makeStyles({
    list: {
        display: "flex",
        flexDirection: "column",
        padding: "16px 0px",

        "& :not(:first-child)": { marginTop: "16px" }
    }
});

Another option would be to use the selector you propose but on the item slot:

const useClasses = makeStyles({
    list: {

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yifanwww
Comment options

Answer selected by yifanwww
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #18543 on June 14, 2021 08:27.