Icons
Overview
Icons are small SVG shapes, ranging from basic UI shapes to brand logos. NewsKit contains a default set but any of these can be overriden by providing a React component in the icons section of your theme.
Usage
Icons can be used to enhance other elements and content, as well as used inside links or buttons when space is limited.
Available Icons
Name | Preview |
---|---|
IconFilledYoutube | |
IconFilledGitHub | |
IconFilledFacebook | |
IconFilledTwitter | |
IconFilledWhatsApp | |
IconFilledFigma |
Props
Icons must have a size specified, and some also support an optional colour override.
Playground
Create NewsKit icons
With the help of the customToNewsKitIcon
util function, each SVG icon can be easily turned into a Newskit icon that works well
with theme tokens and getFromTheme
util functions. The only requirement is to wrap the SVG markup within an Svg
component and pass props to it.
The following example shows how the SVG component should be used:
1
2 <Svg {...props} viewBox="0 0 429 422">
3 <g fill="none" fillRule="evenodd" transform="translate(-77.000000, -1738.000000) translate(77.000000, 1738.500000)">
4 <circle cx="250.5" cy="242.5" r="178" style="mix-blend-mode:multiply"/>
5 <circle cx="195" cy="195" r="195" style="mix-blend-mode:multiply"/>
6 </g>
7 </Svg>
8
Use customToNewsKitIcon
utility function to make the svg icon compatible with NewsKit:
1
2export const IconFilledFacebook = customToNewsKitIcon(
3 'IconFilledFacebook',
4 props => (
5 <Svg {...props} viewBox="0 0 24 24">
6 <path
7 fillRule="nonzero"
8 d="M13.0784931,22.2595724 L13.0784931,13.1365112 L16.2002321,13.1365112 L16.6676019,9.5811424 L13.0784931,9.5811424 L13.0784931,7.31114568 C13.0784931,6.28180493 13.3699223,5.58025387 14.8748197,5.58025387 L16.7941176,5.57938466 L16.7941176,2.39951562 C16.4620261,2.35634473 15.3227937,2.25957241 13.9973813,2.25957241 C11.2301818,2.25957241 9.33569472,3.916388 9.33569472,6.9592112 L9.33569472,9.58123898 L6.20588235,9.58123898 L6.20588235,13.1366078 L9.33559627,13.1366078 L9.33559627,22.2595724 L13.0784931,22.2595724 Z"
9 />
10 </Svg>
11 ),
12);
13
Rationale
Accessibility
Where icon colour can be overidden, the icon must have a 3:1 minimum contrast ratio with its background.