Skip to content

Commit 96f95ef

Browse files
rohanravRohan Ravindran
andauthored
docs: add 'as' prop documentation (react-bootstrap#6007)
* docs: add 'as' prop documentation * docs: update 'as' prop documentation explanation Co-authored-by: Rohan Ravindran <[email protected]>
1 parent 0237a14 commit 96f95ef

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

www/src/examples/AsProp.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Row className="mx-0">
2+
<Button as={Col} variant="primary">Button #1</Button>
3+
<Button as={Col} variant="secondary" className="mx-2">Button #2</Button>
4+
<Button as={Col} variant="success">Button #3</Button>
5+
</Row>;

www/src/pages/getting-started/introduction.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import CodeBlock from '../../components/CodeBlock';
33
import BrowserGlobalsCodeBlock from '../../components/BrowserGlobalsCodeBlock';
44
import CssCodeBlock from '../../components/CssCodeBlock';
55
import DocLink from '../../components/DocLink';
6+
import ReactPlayground from '../../components/ReactPlayground';
7+
import AsPropButtonExample from '../../examples/AsProp';
68

79
# Introduction
810

@@ -118,6 +120,21 @@ $theme-colors: (
118120
See [the Bootstrap docs](https://getbootstrap.com/docs/4.4/getting-started/theming/)
119121
for more advanced use cases and details about customizing stylesheets.
120122

123+
## "as" Prop API
124+
125+
With certain React-Bootstrap components, you may want to modify the component or HTML tag
126+
that is rendered.
127+
128+
If you want to keep all the styling of a particular React-Bootstrap component but switch the
129+
component that is finally rendered (whether it's a different React-Bootstrap component, a
130+
different custom component, or a different HTML tag) you can use the "as" Prop to do so.
131+
132+
The example below passes a Column component to the "as" Prop in a Button component. This
133+
ultimately causes a Column component to be rendered but with the same styles as a Button
134+
component.
135+
136+
<ReactPlayground codeText={AsPropButtonExample} />
137+
121138
## Themes
122139

123140
React-Bootstrap is compatible with existing Bootstrap themes. Just

0 commit comments

Comments
 (0)