Skip to content

Instantly share code, notes, and snippets.

@SebastianHGonzalez
Created August 23, 2019 20:37
Show Gist options
  • Save SebastianHGonzalez/37ec87e46dfdc1f45c2bf8e3e2eb6fa4 to your computer and use it in GitHub Desktop.
Save SebastianHGonzalez/37ec87e46dfdc1f45c2bf8e3e2eb6fa4 to your computer and use it in GitHub Desktop.
Styled Components Table
import React from "react";
import styled from "styled-components";
import font from "styled/font";
export const Table = styled.table`
border-collapse: collapse;
background: ${({ theme }) => theme.table.head.background};
`;
export const TableHead = styled.thead`
color: ${({ theme }) => theme.table.head.backgroundContrast};
text-transform: uppercase;
`;
export const TableRow = styled.tr``;
export const TableBody = styled.tbody`
${TableRow} {
border-bottom: 1px solid ${({ theme }) => theme.table.separator};
background: ${({ theme }) => theme.table.background};
}
${TableRow}:nth-child(2n+2) {
background: ${({ theme }) => theme.table.backgroundOdd};
}
`;
export const TableData = styled.td`
${font}
padding: 1rem;
`;
{
"table": {
"head": {
"background": "#F0F0F0",
"backgroundContrast": "#666"
},
"background": "#FFF",
"backgroundOdd": "#FAFAFA",
"separator": "#D4D4D4"
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment