Skip to content

willbutler/react-inline-css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Style component (PoC)

Make your React components visually predictable. React Style components allows you to cascade CSS stylesheets on your components, automatically namespacing them.

Inspired by the SUIT CSS methodology.

Demo:

Mao-mao-mao!

Example:

You write:

		/** @jsx React.DOM */

		var Profile = React.createClass({
			render: function () {
				return (
					<Style sheet="
						.card {
							cursor: pointer;
							margin: 15px;
							padding: 15px;
							text-align: center;
							height: 200px;
						}
						img {
							width: 130px;
							height: 130px;
						}
						p {
							margin: 10px;
						}
						">
						<div className="card">
							<img src="mao.jpg" />
							<p>Mao</p>
						</div>
					</Style>
				);
			}
		});

You get namespaced CSS that works on sub-components (comparable to HTML5 <style scoped>):

<div class="Style-4n412lnmi">
	<div class="card">
		<img src="mao.jpg">
		<p>Mao</p>
	</div>
	<style>
		.Style-4n412lnmi .card { 
		  cursor: pointer; 
		  margin: 15px; 
		  padding: 15px; 
		  text-align: center; 
		  height: 200px; 
		}
		.Style-4n412lnmi img { 
		  width: 130px; 
		  height: 130px; 
		}
		.Style-4n412lnmi p { 
		  margin: 10px; 
		}
	</style>
</div>

For a cascaded effect, see the index.html demo.

About

Write CSS inside your React components!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.4%
  • HTML 2.6%