# zoid example Let's create a login component. We want the user to be able to log in on our site, and to notify the parent window that the user has logged in, without exposing any of the users credentials to the parent window. Take a look at the [demos](http://krakenjs.com/zoid/demo/index.htm) to see this example in action. ### As the component creator First I'd create a spec for the component's interface. I should do this once -- once I've created the component, I can render it multiple times if I need to: ```javascript var MyLoginComponent = zoid.create({ // The html tag used to render my component tag: "my-login-component", // The url that will be loaded in the iframe or popup, when someone includes my component on their page url: "http://www.my-site.com/my-login-component", // The size of the component on their page. Only px and % strings are supported dimensions: { width: "400px", height: "200px", }, // The properties they can (or must) pass down to my component. This is optional. props: { prefilledEmail: { type: "string", required: false, }, onLogin: { type: "function", required: true, }, }, }); ``` This spec describes everything needed to render the component on the parent page, including the props the component expects. Now we need to actually implement the business logic of the component -- the code that will run inside the iframe. I just need to use `window.xprops` to get the props that are passed down. ```html
``` Now anyone can render the component we defined onto their page! ### As the component user My life is even easier. I just need to drop in your component onto my page: ```html ``` I can render a component as many times as I like on my page. This is even easier if you're using a supported framework like React, Ember or Angular -- zoid will automatically set up bindings for these frameworks: ### React / JSX Drop the component in any `render()` method: ```javascript let MyReactLoginComponent = MyLoginComponent.driver("react", { React: React, ReactDOM: ReactDOM, }); ``` ```javascript render: function() { return (