Skip to content

Fluent V9 Button: How do I remove the margin-right styling from the icon span when rendering a button with and icon and children? #30749

Answered by pradeept95
svalenciasan asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @svalenciasan ,
You can customize icon behavior using slot api. following example might help you.

import { Button, makeStyles, shorthands } from '@fluentui/react-components';
import { AddFilled } from '@fluentui/react-icons';

const useButtonStyles = makeStyles({
  buttonIcon: {
    ...shorthands.margin(0),
  },
});

export const ButtonExample = () => {
  const styles = useButtonStyles();

  return (
    <Button
      icon={{
        children: <AddFilled />,
        className: styles.buttonIcon,
      }}
      appearance="primary"
      shape="circular"
    >
      <span style={{ display: 'none' }}>invisible child</span>
    </Button>
  );
};

You can read more how you can customize c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by behowell
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