Skip to content

Commit

Permalink
add react example
Browse files Browse the repository at this point in the history
  • Loading branch information
claviska committed Aug 15, 2022
1 parent 70f59aa commit 23bb45b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/components/popup.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,41 @@ By default, anchors are slotted into the popup using the `anchor` slot. If your
</style>
```

```jsx react
import { SlPopup } from '@shoelace-style/shoelace/dist/react';

const css = `
#external-anchor {
display: inline-block;
width: 150px;
height: 150px;
border: dashed 2px var(--sl-color-neutral-600);
margin: 50px 0 0 50px;
}
#external-anchor ~ sl-popup .box {
width: 100px;
height: 50px;
background: var(--sl-color-primary-600);
border-radius: var(--sl-border-radius-medium);
}
`;

const App = () => {
return (
<>
<span id="external-anchor" />

<SlPopup anchor="external-anchor" placement="top" active>
<div class="box" />
</SlPopup>

<style>{css}</style>
</>
);
};
```

### Placement

Use the `placement` attribute to tell the popup the preferred placement of the popup. Note that the actual position will vary to ensure the panel remains in the viewport if you're using positioning features such as `flip` and `shift`.
Expand Down

0 comments on commit 23bb45b

Please sign in to comment.