Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

How to use Styled-Components

// INSTALL:
npm install --save styled-components

// IMPORT: i prefer to create a file for each component. Ex.: Button-Styled.js 
// (rather than a single file with all styled components, gets messy)
import styled from 'styled-components'

// USE: create a new file called componentName-Styled.js
// define a var with the name of the component = styled.htmltag`CSS styles`
const Button = styled.button`
  background: transparent;
  border-radius: 3px;
  border: 2px solid palevioletred;
  color: palevioletred;
  margin: 0 1em;
  padding: 0.25em 1em;
`
Comment

how to create styled components

import styled from 'styled-component';

// Create a Title component that'll render an <h1> tag with some styles
const Title = styled.h1`
  font-size: 1.5em;
  text-align: center;
  color: palevioletred;
`;

// Create a Wrapper component that'll render a <section> tag with some styles
const Wrapper = styled.section`
  padding: 4em;
  background: papayawhip;
`;

// Use Title and Wrapper like any other React component – except they're styled!
render(
  <Wrapper>
    <Title>
      Hello World!
    </Title>
  </Wrapper>
);
Comment

styled componennts

npm install --save styled-componentsnpm install --save styled-components
Comment

styled components tw

const Button = tw.div`
    ${(p) => (p.$primary ? "bg-indigo-600" : "bg-indigo-300")}

    flex
    inline-flex
    items-center
    border
    border-transparent
    text-xs
    font-medium
    rounded
    shadow-sm
    text-white

    hover:bg-indigo-700
    focus:outline-none
`
Comment

PREVIOUS NEXT
Code Example
Typescript :: install dependencies angular 
Typescript :: node scripts delay 
Typescript :: real time charts in flutter 
Typescript :: whats a company letterhead 
Typescript :: type char typescript 
Typescript :: typescript read url search params 
Typescript :: fusion builder elegant elements for free 
Typescript :: Number of power set of {a, b}, where a and b are distinct elements. 
Typescript :: instruments du marché monétaire 
Typescript :: git@github.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 
Cpp :: c++ clear console 
Cpp :: sfml local mouse position 
Cpp :: ob for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details. 
Cpp :: how to print numbers with only 2 digits after decimal point in c++ 
Cpp :: c++ hide cursor 
Cpp :: std::string to qstring 
Cpp :: rng c++ 
Cpp :: prime number generator c++ 
Cpp :: how to print hello world in c++ 
Cpp :: error: ‘memset’ was not declared in this scope in cpp 
Cpp :: exp() c++ 
Cpp :: resizing dynamic array c++ 
Cpp :: replace character in a string c++ stack overflow 
Cpp :: how to delete a 2d dynamic array in c++ 
Cpp :: c++ unary minus overload 
Cpp :: c++ std::find with lambda 
Cpp :: qt label set text color 
Cpp :: addition without arithmetic operators c++ 
Cpp :: make random nuber between two number in c++ 
Cpp :: arduino notone 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =