Subscribe Us

header ads

Penggunaan CSS Inline dengan styled-component di React

 Berikut Penggunaan CSS Inline dengan styled-component di React

sebelum menggunakannya install lybrary styled component : npm install styled-components


Berikut contoh kodenya :

import React from "react";
import styled from "styled-components";

const Button = styled.button`
  background-color: ${(props) => (props.primary ? "blue" : "gray")};
  color: white;
  padding: 10px 20px;
  border: 5px;
`;

export default function App() {
  return (
    <div>
      <Button primary>Primary Button</Button>
      <Button>Secondary Button</Button>
    </div>
  );
}

berikut hasilnya :



Posting Komentar

0 Komentar