forked from callstack/react-native-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicons.html
43 lines (43 loc) · 10.7 KB
/
icons.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<html lang="en" data-reactroot=""><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/><meta name="mobile-web-app-capable" content="yes"/><meta name="apple-mobile-web-app-capable" content="yes"/><meta name="description" content=""/><meta name="twitter:card" content="summary"/><meta name="twitter:title" content="Icons"/><meta name="twitter:description" content=""/><meta property="og:type" content="website"/><meta property="og:title" content="Icons"/><meta property="og:description" content=""/><title>Icons</title><link type="text/css" rel="stylesheet" href="app.css"/></head><body><div id='root'><div class="_wrapper__1nbmuhq" data-reactroot=""><aside class="_sidebar__1gt5k1p"><input type="checkbox" class="_menuButton__1gt5k1p" id="slide-sidebar" role="button"/><label class="_menuIcon__1gt5k1p" for="slide-sidebar">☰</label><div class="_menu__1gt5k1p"><input type="search" value="" placeholder="Filter…" class="_searchbar__1gt5k1p"/><nav class="_navigation__1gt5k1p"><a class="_link__1gt5k1p" href="index.html">Home</a><a class="_link__1gt5k1p" href="showcase.html">Showcase</a><a class="_link__1gt5k1p" href="getting-started.html">Getting Started</a><a class="_link__1gt5k1p" href="theming.html">Theming</a><a class="_link__1gt5k1p _active__1gt5k1p" href="icons.html">Icons</a><a class="_link__1gt5k1p" href="contributing.html">Contributing</a><hr class="_separator__1gt5k1p"/><a class="_link__1gt5k1p" href="bottom-navigation.html">BottomNavigation</a><a class="_link__1gt5k1p" href="button.html">Button</a><a class="_link__1gt5k1p" href="caption.html">Caption</a><a class="_link__1gt5k1p" href="card.html">Card</a><a class="_link__1gt5k1p" href="card-actions.html">CardActions</a><a class="_link__1gt5k1p" href="card-content.html">CardContent</a><a class="_link__1gt5k1p" href="card-cover.html">CardCover</a><a class="_link__1gt5k1p" href="checkbox.html">Checkbox</a><a class="_link__1gt5k1p" href="chip.html">Chip</a><a class="_link__1gt5k1p" href="dialog.html">Dialog</a><a class="_link__1gt5k1p" href="dialog-actions.html">DialogActions</a><a class="_link__1gt5k1p" href="dialog-content.html">DialogContent</a><a class="_link__1gt5k1p" href="dialog-scroll-area.html">DialogScrollArea</a><a class="_link__1gt5k1p" href="dialog-title.html">DialogTitle</a><a class="_link__1gt5k1p" href="divider.html">Divider</a><a class="_link__1gt5k1p" href="drawer-item.html">DrawerItem</a><a class="_link__1gt5k1p" href="drawer-section.html">DrawerSection</a><a class="_link__1gt5k1p" href="fab.html">FAB</a><a class="_link__1gt5k1p" href="fabgroup.html">FABGroup</a><a class="_link__1gt5k1p" href="headline.html">Headline</a><a class="_link__1gt5k1p" href="helper-text.html">HelperText</a><a class="_link__1gt5k1p" href="list-accordion.html">ListAccordion</a><a class="_link__1gt5k1p" href="list-item.html">ListItem</a><a class="_link__1gt5k1p" href="list-section.html">ListSection</a><a class="_link__1gt5k1p" href="modal.html">Modal</a><a class="_link__1gt5k1p" href="paper.html">Paper</a><a class="_link__1gt5k1p" href="paragraph.html">Paragraph</a><a class="_link__1gt5k1p" href="progress-bar.html">ProgressBar</a><a class="_link__1gt5k1p" href="radio-button.html">RadioButton</a><a class="_link__1gt5k1p" href="radio-button-group.html">RadioButtonGroup</a><a class="_link__1gt5k1p" href="searchbar.html">Searchbar</a><a class="_link__1gt5k1p" href="snackbar.html">Snackbar</a><a class="_link__1gt5k1p" href="subheading.html">Subheading</a><a class="_link__1gt5k1p" href="switch.html">Switch</a><a class="_link__1gt5k1p" href="text.html">Text</a><a class="_link__1gt5k1p" href="text-input.html">TextInput</a><a class="_link__1gt5k1p" href="title.html">Title</a><a class="_link__1gt5k1p" href="toolbar.html">Toolbar</a><a class="_link__1gt5k1p" href="toolbar-action.html">ToolbarAction</a><a class="_link__1gt5k1p" href="toolbar-back-action.html">ToolbarBackAction</a><a class="_link__1gt5k1p" href="toolbar-content.html">ToolbarContent</a><a class="_link__1gt5k1p" href="touchable-ripple.html">TouchableRipple</a></nav></div></aside><div class="_container__z02bld"><main class="_content__z02bld"><div class="_markdown__1e8xr4b"><h2>Configuring icons</h2>
<p>Many of the components require the <a href="https://github.com/oblador/react-native-vector-icons">react-native-vector-icons</a> library to render correctly. If you're using CRNA or Expo, you don't need to do anything extra, but if it's vanilla React Native project, you need link the library as described in the getting started guide.</p>
<p>If you opted out of vector icons support using <a href="https://github.com/satya164/babel-plugin-optional-require">babel-plugin-optional-require</a>, you won't be able to use icon names for the icon prop anymore. Some components may not look correct without vector icons and might need extra configuration.</p>
<h2>Using the <code>icon</code> prop</h2>
<p>Many components such as <code>Button</code> accept an <code>icon</code> prop which is used to display an icon. The <code>icon</code> prop supports the following type of values:</p>
<h3>1. An icon name</h3>
<p>You can pass the name of an icon from <a href="https://material.io/icons/"><code>MaterialIcon</code></a>. This will use the <a href="https://github.com/oblador/react-native-vector-icons"><code>react-native-vector-icons</code></a> library to display the icon.</p>
<p>Example:</p>
<pre><code class="language-js"><span class="token tag" ><span class="token tag" ><span class="token punctuation" ><</span>Button</span> <span class="token attr-name" >icon</span><span class="token attr-value" ><span class="token punctuation" >=</span><span class="token punctuation" >"</span>add-a-photo<span class="token punctuation" >"</span></span><span class="token punctuation" >></span></span>
Press me
<span class="token tag" ><span class="token tag" ><span class="token punctuation" ></</span>Button</span><span class="token punctuation" >></span></span>
</code></pre>
<h3>2. An image source</h3>
<p>You can pass an image source, such as an object of shape <code>{ uri: 'https://path.to' }</code> or a local image: <code>require('../path/to/image.png')</code> to use as an icon. The image might be rendered with a different color than the one provided depending on the component. If don't want this behavior, see the next example to pass an <code>Image</code> element.</p>
<p>Remote image:</p>
<pre><code class="language-js"><span class="token tag" ><span class="token tag" ><span class="token punctuation" ><</span>Button</span> <span class="token attr-name" >icon</span><span class="token script language-javascript" ><span class="token punctuation" >=</span><span class="token punctuation brackets-braces" >{</span><span class="token punctuation brackets-braces" >{</span> uri<span class="token punctuation" >:</span> <span class="token string" >'https://avatars0.githubusercontent.com/u/17571969?v=3&s=400'</span> <span class="token punctuation brackets-braces" >}</span><span class="token punctuation brackets-braces" >}</span></span><span class="token punctuation" >></span></span>
Press me
<span class="token tag" ><span class="token tag" ><span class="token punctuation" ></</span>Button</span><span class="token punctuation" >></span></span>
</code></pre>
<p>Local image:</p>
<pre><code class="language-js"><span class="token tag" ><span class="token tag" ><span class="token punctuation" ><</span>Button</span> <span class="token attr-name" >icon</span><span class="token script language-javascript" ><span class="token punctuation" >=</span><span class="token punctuation brackets-braces" >{</span><span class="token function" >require</span><span class="token punctuation brackets-parentheses" >(</span><span class="token string" >'../assets/chameleon.jpg'</span><span class="token punctuation brackets-parentheses" >)</span><span class="token punctuation brackets-braces" >}</span></span><span class="token punctuation" >></span></span>
Press me
<span class="token tag" ><span class="token tag" ><span class="token punctuation" ></</span>Button</span><span class="token punctuation" >></span></span>
</code></pre>
<h3>3. A render function</h3>
<p>You can pass a function which returns a react element to be used an icon. The function receives an object with <code>size</code> and <code>color</code> properties as it's argument. element is used as is without any modification. However, it might get clipped if the provided element's size are bigger than what the component renders. It's upto you to make sure that the size of the element is correct.</p>
<p>Example:</p>
<pre><code class="language-js"><span class="token tag" ><span class="token tag" ><span class="token punctuation" ><</span>Button</span>
<span class="token attr-name" >icon</span><span class="token script language-javascript" ><span class="token punctuation" >=</span><span class="token punctuation brackets-braces" >{</span><span class="token punctuation brackets-parentheses" >(</span><span class="token punctuation brackets-braces" >{</span> size<span class="token punctuation" >,</span> color <span class="token punctuation brackets-braces" >}</span><span class="token punctuation brackets-parentheses" >)</span> <span class="token operator" >=</span><span class="token operator" >></span> <span class="token punctuation brackets-parentheses" >(</span>
<span class="token operator" ><</span>Image
source<span class="token punctuation" >=</span><span class="token punctuation brackets-braces" >{</span><span class="token function" >require</span><span class="token punctuation brackets-parentheses" >(</span><span class="token string" >'../assets/chameleon.jpg'</span><span class="token punctuation brackets-parentheses" >)</span><span class="token punctuation brackets-braces" >}</span>
style<span class="token punctuation" >=</span><span class="token punctuation brackets-braces" >{</span><span class="token punctuation brackets-braces" >{</span> width<span class="token punctuation" >:</span> size<span class="token punctuation" >,</span> height<span class="token punctuation" >:</span> size<span class="token punctuation" >,</span> tintColor<span class="token punctuation" >:</span> color <span class="token punctuation brackets-braces" >}</span><span class="token punctuation brackets-braces" >}</span></span>
<span class="token punctuation" >/></span></span>
<span class="token punctuation brackets-parentheses" >)</span><span class="token punctuation brackets-braces" >}</span>
<span class="token operator" >></span>
Press me
<span class="token tag" ><span class="token tag" ><span class="token punctuation" ></</span>Button</span><span class="token punctuation" >></span></span>
</code></pre>
</div></main></div></div></div>
<script>
window.__INITIAL_PATH__ = 'icons';
</script>
<script src="app.bundle.js"></script></body></html>