{"id":13528967,"url":"https://playcanvas.github.io/pcui","last_synced_at":"2025-04-01T14:33:45.923Z","repository":{"id":38085816,"uuid":"286531410","full_name":"playcanvas/pcui","owner":"playcanvas","description":"UI component library for web-based tools","archived":false,"fork":false,"pushed_at":"2025-03-27T09:57:14.000Z","size":9171,"stargazers_count":699,"open_issues_count":23,"forks_count":68,"subscribers_count":19,"default_branch":"main","last_synced_at":"2025-03-28T19:38:27.928Z","etag":null,"topics":["pcui","playcanvas","react","sass","typescript","ui","ui-components"],"latest_commit_sha":null,"homepage":"https://developer.playcanvas.com/user-manual/pcui/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/playcanvas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-10T16:55:02.000Z","updated_at":"2025-03-27T12:21:01.000Z","dependencies_parsed_at":"2022-07-12T17:12:02.257Z","dependency_job_id":"cd930f43-5d00-4b81-8437-279db32401f5","html_url":"https://github.com/playcanvas/pcui","commit_stats":{"total_commits":410,"total_committers":21,"mean_commits":"19.523809523809526","dds":0.578048780487805,"last_synced_commit":"1d2260815dd5b4c5616c7119f069c21aec01973f"},"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fpcui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fpcui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fpcui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/playcanvas%2Fpcui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/playcanvas","download_url":"https://codeload.github.com/playcanvas/pcui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246655492,"owners_count":20812644,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pcui","playcanvas","react","sass","typescript","ui","ui-components"],"created_at":"2024-08-01T07:00:30.077Z","updated_at":"2025-04-01T14:33:45.914Z","avatar_url":"https://github.com/playcanvas.png","language":"TypeScript","funding_links":[],"categories":["PlayCanvas"],"sub_categories":[],"readme":"# PCUI - User Interface Component Library for the Web\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/playcanvas/pcui/blob/main/LICENSE)\n[![NPM Version](https://img.shields.io/npm/v/@playcanvas/pcui.svg?style=flat?style=flat)](https://www.npmjs.com/package/@playcanvas/pcui)\n[![NPM Downloads](https://img.shields.io/npm/dw/@playcanvas/pcui)](https://npmtrends.com/@playcanvas/pcui)\n\n| [User Guide](https://developer.playcanvas.com/user-manual/pcui/) | [API Reference](https://api.playcanvas.com/pcui/) | [ESM Examples](https://playcanvas.github.io/pcui/examples/) | [React Examples](https://playcanvas.github.io/pcui/storybook/) | [Blog](https://blog.playcanvas.com/) | [Forum](https://forum.playcanvas.com/) | [Discord](https://discord.gg/RSaMRzg) |\n\n![PCUI Banner](https://forum-files-playcanvas-com.s3.dualstack.eu-west-1.amazonaws.com/original/2X/7/7e51de8ae69fa499dcad292efd21d7722dcf2dbd.jpeg)\n\nThis library enables the creation of reliable and visually pleasing user interfaces by providing fully styled components that you can use directly on your site. The components are useful in a wide range of use cases, from creating simple forms to building graphical user interfaces for complex web tools.\n\nA full guide to using the PCUI library can be found [here](https://developer.playcanvas.com/user-manual/pcui/).\n\n## Getting Started\n\nTo install the PCUI NPM module, run the following command:\n\n    npm install @playcanvas/pcui --save-dev\n\nYou can then import each individual element from PCUI. In the example below, you can see how the PCUI `Label` component is imported from the PCUI library. The styles for PCUI are then imported into the example. Styles only need to be imported once per project.\n\n```javascript\nimport { Label } from '@playcanvas/pcui';\nimport '@playcanvas/pcui/styles';\n\nconst label = new Label({\n    text: 'Hello World'\n});\ndocument.body.appendChild(label.dom);\n```\n\nIf you'd like to include PCUI in your React project, you can import the individual components as follows:\n\n```javascript\nimport * as React from 'react';\nimport ReactDOM from 'react-dom';\nimport { TextInput } from '@playcanvas/pcui/react';\nimport '@playcanvas/pcui/styles';\n\nReactDOM.render(\n    \u003cTextInput text='Hello World'/\u003e,\n    document.body\n);\n```\n\n## Building a UMD bundle\n\nIf you need a UMD version of the PCUI library (say, to use it in a PlayCanvas Editor project), please refer to our [build guide](BUILDGUIDE.md).\n\n## Fonts in PCUI\n\nPCUI uses four CSS classes for fonts across its components: `.font-regular`, `.font-bold`, `.font-thin` and `.font-light`. By default, these use the Helvetica Neue font stack:\n\n```css\n    font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;\n```\n\n### Using your own Font\n\nYou can override PCUI's default font by adding your own `font-family` CSS rules to these classes on your webpage:\n\n```css\n.font-regular, .font-bold, .font-thin, .font-light {\n    font-family: 'Your Font', sans-serif;\n}\n```\n\n## Data Binding\n\nThe PCUI library offers a data binding layer that can be used to synchronize data across multiple components. It offers two way binding to a given observer object, so updates made in a component are reflected in the observer's data and distributed out to all other subscribed components. A simple use case is shown below:\n\n```javascript\nimport { Observer } from '@playcanvas/observer';\nimport { Label, TextInput, BindingObserversToElement, BindingElementToObservers } from '@playcanvas/pcui';\nimport '@playcanvas/pcui/styles';\n\n// create a new observer for a simple object which contains a text string\nconst observer = new Observer({\n    text: 'Hello World'\n});\n\n// create a label which will listen to updates from the observer\nconst label = new Label({\n    binding: new BindingObserversToElement()\n});\n\n// link the observer to the label, telling it to use the text variable as its value\nlabel.link(observer, 'text');\n\n// create a text input which will send updates to the observer\nconst textInput = new TextInput({\n    binding: new BindingElementToObservers()\n});\n\n// link the observer to the label, telling it to set the text variable on change\ntextInput.link(observer, 'text');\n```\n\nIn the above example, the created label will start with `Hello World` as its text value. When a user enters a value into the text input, the label will be updated with the new value.\n\nObservers can also be bound bi-directionally, in which case an element can both send and receive updates through its observer. The following example shows a two way binding between two text inputs, where either input can update the value of the other. It's been written in React to showcase binding with React components:\n\n```jsx\nimport { Observer } from '@playcanvas/observer';\nimport { BindingTwoWay, TextInput } from '@playcanvas/pcui/react';\nimport '@playcanvas/pcui/styles';\n\n// create a new observer for a simple object which contains a text string\nconst observer = new Observer({\n    text: 'Hello World'\n});\n\n// create two text inputs, which can both send and receive updates through the linked observer\nconst TextInput1 = () =\u003e \u003cTextInput binding={new BindingTwoWay()} link={{ observer, path: 'text'} /\u003e;\nconst TextInput2 = () =\u003e \u003cTextInput binding={new BindingTwoWay()} link={{ observer, path: 'text'} /\u003e;\n```\n\n## Development\n\nEach component exists in its own folder within the `./src/components` directory. They each contain:\n\n- `index.ts`: The PCUI element.\n- `style.scss`: The SASS styles for the PCUI element.\n- `component.tsx`: A React component wrapping the PCUI element.\n- `component.stories.tsx`: The Storybook entry for the React component.\n\nLocally developed components can be viewed \u0026 tested by running the Storybook app, as mentioned in the following section.\n\nIf you'd like to build your own custom version of the library you can run the `npm run build` command which will create a `dist` directory with your custom build.\n\n## Storybook\n\nIf you wish to view all components available to you in the library, you can run a local version Storybook. It allows you to browse the entire collection of components and test any changes you make to them. Each component page also includes component documentation and allows you to test each component in all of its configuration states.\n\nRun Storybook as follows:\n\n    npm install\n    npm run storybook\n\n## API Documentation\n\nTo build the PCUI API Reference to the `docs` folder, do:\n\n```bash\nnpm run docs\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/playcanvas.github.io%2Fpcui","html_url":"https://awesome.ecosyste.ms/projects/playcanvas.github.io%2Fpcui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/playcanvas.github.io%2Fpcui/lists"}