React

[React] semantic-ui Button 커스텀 하기

먹세 2023. 3. 22. 11:08

기본 사용

/* index.js */
import {Button} from "semantic-ui-react";

<Styles.BtnWrap>
    <Button basic onClick={() => location.href='/'}>
        홈 이동
    </Button>
    <Button secondary basic onClick={() => location.href='/'}>
        홈 이동
    </Button>
    <Button primary onClick={() => location.href='/'}>
        홈 이동
    </Button>
    <Button negative onClick={() => location.href='/'}>
        홈 이동
    </Button>
</Styles.BtnWrap>

 

커스텀

/* index.js */
import {Button} from "semantic-ui-react";

<Styles.BtnWrap>
    <Button className="btn-1" onClick={() => location.href='/'}>
        홈 이동
    </Button>
</Styles.BtnWrap>
/* style.js */

export const BtnWrap = styled.div.attrs(props => ({}))`
  margin-top: 25px;
  
  & .ui.button.btn-1 {
    color: #fff;
    padding: 5px 14px;
    border-radius: 4px;
    background-color: #484848;
  }
  
`;

.ui.button 은 semantic-ui button의 기본 css class 이므로, 이를 활용하여 커스텀 가능.

 

 

 

https://react.semantic-ui.com/elements/button/

 

Button - Semantic UI React

When Button is attached or rendered as non-button element, it losses ability to handle keyboard events when it focused. However, button behaviour can be replicated with onKeyPress handler. You can find out more details on MDN.

react.semantic-ui.com

 

반응형