Skip to content

Commit c9932fd

Browse files
Added Style tag to documentation
1 parent 2cc0474 commit c9932fd

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

README.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Welcome to the React Unity WebGL Documentation! My name is Jeffrey and I'm here
5656
- [Tracking the loading progression](#tracking-the-loading-progression)
5757
- [Handeling on when the Application is loaded](#handeling-on-when-the-application-is-loaded)
5858
- [Entering or Leaving Fullscreen](#entering-or-leaving-fullscreen)
59-
- [Setting the Canvas's Height and Width](#setting-the-canvass-height-and-width)
59+
- [Adding Styles to the Canvas Component](#adding-styles-to-the-canvas-component)
6060
- [Setting the Canvas's ClassName](#setting-the-canvass-classname)
6161
- [Device Pixel Ratio and Retina Support](#device-pixel-ratio-and-retina-support)
6262
- [Tab Index and Keyboard Capturing](#tab-index-and-keyboard-capturing)
@@ -397,16 +397,16 @@ const App = () => {
397397
};
398398
```
399399

400-
## Setting the Canvas's Height and Width
400+
## Adding Styles to the Canvas Component
401401

402-
> Available since version 5.6.0
402+
> Available since version 8.2.0
403403
404-
The default size is 800px width to 600px height. You can easily overrule them by passing the following props. The height and width properties are used to set the height and width of the wrapper element.
404+
The style tag allows for adding inline CSS for styling the component. The style's properties will be assigned directly onto the actual canvas.
405405

406-
The height and width can be set to auto (Means that the browser calculates the height and width), or be specified in length values, like px, cm, etc., or in percent of the containing block. Note that the height and width properties do not include padding, borders, or margins; they set the height/width of the area inside the padding, border, and margin of the element!
406+
The style attribute accepts a JavaScript object with camelCased properties rather than a CSS string. This is consistent with the DOM style JavaScript property, is more efficient, and prevents XSS security holes. React will automatically append a “px” suffix to certain numeric inline style properties. If you want to use units other than “px”, specify the value as a string with the desired unit.
407407

408408
```tsx
409-
<Unity height={number | string} width={number | string} />
409+
<Unity style={CSSProperties} />
410410
```
411411

412412
#### Example implementation
@@ -427,7 +427,17 @@ const unityContext = new UnityContext({
427427
});
428428

429429
const App = () => {
430-
return <Unity unityContext={unityContext} width="100%" height="950px" />;
430+
return (
431+
<Unity
432+
unityContext={unityContext}
433+
style={{
434+
height: "100%",
435+
width: 950,
436+
border: "2px solid black",
437+
background: "grey",
438+
}}
439+
/>
440+
);
431441
};
432442
```
433443

0 commit comments

Comments
 (0)